package com.cloud.base.thread.thread;

import com.cloud.base.thread.future.FutureEntity;
import lombok.SneakyThrows;

import java.util.concurrent.FutureTask;

public class ThreadMain {
    @SneakyThrows
    public static void main(String[] args) {
        //创建线程的四种方式
        new Thread(()->{
            System.out.println("hello");
        }).start();
        //继承Thread
        ThreadEntity threadEntity = new ThreadEntity();
        threadEntity.start();
        //重写runnable
        new Thread(new RunnableEntity()).start();
        //实现callable
        FutureEntity futureEntity = new FutureEntity();
        FutureTask<String> task = new FutureTask(futureEntity);
        new Thread(task).start();
        System.out.println(task.get());

    }
}
